package com.sxhuayuan.parking.dao;

import java.util.List;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.sxhuayuan.parking.entity.MemberCarPlate;

public interface MemberCarPlateDao extends BaseDao<MemberCarPlate, Long> {

	@Query(value = "select * from  hypk_member_car_plate where member_id = :memberId", nativeQuery = true)
	List<MemberCarPlate> findByMemberList(@Param("memberId") Long memberId);

	/**
	 * 根据车牌号和用户查询
	 */
	@Query(value = "select * from  hypk_member_car_plate where member_id = ?1 and car_plate = ?2", nativeQuery = true)
	MemberCarPlate findByMemberIdAndCarPlate(Long memberId, String carPlate);

	@Modifying
	@Query(value = "update hypk_member_car_plate set is_def=0 where member_id = ?1", nativeQuery = true)
	void cancelAllCarPlateDef(Long memberId);
}
